trigger sendMailAfterUpdate on Plan_Document_Inquiry__c (after Update) {
//URL__c url = [select Url_Value__c from URL__c];
if(Trigger.isUpdate){
       for(Plan_Document_Inquiry__c p: Trigger.new){
          if(p.InquiryStatus__c == 'Inquiry Approved' || p.InquiryStatus__c == 'Inquiry Rejected') {
                Sales_Contract__c pd = [Select UserID__c,Status__c from Sales_Contract__c sc where sc.Id = :p.Plan_Document__c];
                
                User u = [Select FirstName, Email from User us where us.Id = :pd.UserID__c];
                String firstName = u.FirstName;
                
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            
                // Strings to hold the email addresses to which you are sending the email.
                String[] toAddresses = new String[] {u.Email}; 
                String[] ccAddresses = new String[] {};
              
            
                // Assign the addresses for the To and CC lists to the mail object.
                mail.setToAddresses(toAddresses);
                mail.setCcAddresses(ccAddresses);
            
                // Specify the address used when the recipients reply to the email. 
//                mail.setReplyTo('prashanth.pittala@sierraatlantic.com');
            
                // Specify the name used as the display name.
                mail.setSenderDisplayName('Salesforce OnDemand');
            
                // Specify the subject line for your email address.
                mail.setSubject(''+p.Name+'');
            
                // Set to True if you want to BCC yourself on the email.
                mail.setBccSender(false);
                
            
                // Optionally append the salesforce.com email signature to the email.
                // The email address of the user executing the Apex Code will be used.
                mail.setUseSignature(false);
                
     
                // Specify the text content of the email.
                mail.setPlainTextBody('Your Plan Document Inquiry is approved.');
                
                mail.setHtmlBody('Dear <b>'+u.FirstName+'</b>,<br/><br/>Your Plan Document Inquiry is processed.<br/><a href="'+p.Url__c+'/'+p.Id+'">Click here</a> to view.');
            
                // Send the email you have created.
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
           }    
       }
     }
}